package com.usian.order.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.usian.common.Result;
import com.usian.common.ResultCodeEnum;
import com.usian.entity.PaymentRecords;
import com.usian.order.mapper.PaymentRecordsMapper;
import com.usian.order.service.IPaymentRecordsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author author
 * @since 2025-01-15
 */
@Service
public class PaymentRecordsServiceImpl extends ServiceImpl<PaymentRecordsMapper, PaymentRecords> implements IPaymentRecordsService {

    @Override
    public Result<PaymentRecords> getPaymentRecordsByOrderId(Integer orderId) {
        LambdaQueryWrapper<PaymentRecords> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(PaymentRecords::getOrderId, orderId);
        PaymentRecords paymentRecords = getOne(wrapper);
        System.out.println("paymentRecords=============" + paymentRecords);
        if (paymentRecords == null) {
            return Result.build(null, ResultCodeEnum.DATA_NOT_EXISTS);
        }
        return Result.build(paymentRecords, ResultCodeEnum.SUCCESS);
    }

}
